﻿@model ZhongheCms.Models.GswTblJobInfo
@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var strChk = "";
    var strChk1 = "";
    if (Model.ReFlag == 1)
    {
        strChk = "checked";
    }
    if (Model.HotFlag == 1)
    {
        strChk1 = "checked";
    }
    var strSelect = "";
  
    var s0 = "";
     var s1 = "";
    if (Model.JobState > 0)
    {
        s0 = "selected";
    }
    else
    {
        s1 = "selected";
    }
        
}
@section css{

    <link rel="stylesheet" href="/kindeditor/themes/default/default.css" />
    <link rel="stylesheet" href="/Assets/webuploader/webuploader.css" />
    <link href="/Assets/css/select2.css" rel="stylesheet">
    <link href="/Assets/css/select2-bootstrap.css" rel="stylesheet">
    <link rel="stylesheet" href="/Assets/css/datepicker.css" />
}
<div class="row">
    <div class="col-xs-12 col-sm-12 widget-container-col">
        @using (Html.BeginForm("PubAuditView", "JobInfo", new { id = Model.Id, ViewBag.m, ViewBag.f, ViewBag.p, ViewBag.fid, ViewBag.sdate, ViewBag.edate, ViewBag.jname,ViewBag.pageIndex}, FormMethod.Post,
            new { name = "myForm", id = "myForm", @class = "form-horizontal", role = "form" }))
        {
            <div class="widget-box">
                <div class="widget-header">
                    <h5 class="widget-title">@ViewBag.f  @if (!string.IsNullOrEmpty(ViewBag.p))
                                                         {
                            <span>(@ViewBag.p)</span>
                                                         }</h5>

                    <div class="widget-toolbar">
                    </div>
                </div>

                <div class="widget-body">


                    <div class="widget-main">

                        <div class="form-group">
                            <table id="sample-table-1" class="table table-bordered table-hover">
                                <tbody>
                                    <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">发布日期
                                        </td>
                                        <td>

                                            <input  id="PubDate" name="PubDate" placeholder="" type="text" class="form-control" value="@Model.PubDate.ToShortDateString()"  />

                                        </td>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">截止日期
                                        </td>
                                        <td>

                                            <input  id="EndDate" name="EndDate" placeholder="" type="text" class="form-control" value="@Model.EndDate.ToShortDateString()"  />

                                        </td>

                                    </tr>
                                     <tr>
                                        @*<td class="align-right" style="width: 15%; background: #f6f6f6">招聘单位
                                        </td>
                                        <td>
                                              <input  id="CustomerId" name="CustomerId" placeholder="" type="text" class="form-control" value="@Model.CustomerId"  />
                                           

                                        </td>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">单位别名
                                        </td>
                                        <td>

                                            <input type="text" id="CustomerAlias" name="CustomerAlias" placeholder="" class="form-control" value="@Model.CustomerAlias"  />
                                           

                                        </td>*@

                                         <td class="align-right" style="width: 15%; background: #f6f6f6">
                                             招聘单位
                                         </td>
                                         <td colspan="3">
                                             <input id="CusShortName" name="CusShortName" placeholder="" type="text" class="form-control" value="@Model.CusShortName" data-val="true" data-val-required="招聘单位不允许为空" />
                                             <span class="field-validation-valid help-block" data-valmsg-for="CusShortName" data-valmsg-replace="true"></span>



                                         </td>
                                     </tr>
                                    <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">职位类别
                                        </td>
                                        <td>

                                            <select class="form-control" id="JobTypeId" name="JobTypeId">
                                              
                                                @foreach (var item in Model.BaseInfos.Where(x => x.FunctionName.Trim() == "职位类别"))
                                                {
                                                   
                                                        strSelect = "";
                                                        if (Model.JobTypeId == item.Id)
                                                        {
                                                            strSelect = "selected";
                                                        }
                                                        <option value="@item.Id" @strSelect>@item.MasterType</option>
                                                    }
                                                   
                                                }
                                            </select>

                                        </td>
                                         <td class="align-right" style="width: 15%; background: #f6f6f6">工作类型
                                        </td>
                                        <td>

                                            <select class="form-control" id="WorkTypeId" name="WorkTypeId">
                                              
                                                @foreach (var item in Model.BaseInfos.Where(x => x.FunctionName.Trim() == "工作类型"))
                                                {
                                                   
                                                        strSelect = "";
                                                        if (Model.JobTypeId == item.Id)
                                                        {
                                                            strSelect = "selected";
                                                        }
                                                        <option value="@item.Id" @strSelect>@item.MasterType</option>
                                                    }
                                                   
                                                }
                                            </select>

                                        </td>
                                       

                                    </tr>
                                    <tr>
                                         <td class="align-right" style="width: 15%; background: #f6f6f6">职位编号
                                        </td>
                                        <td>

                                            <input type="text" id="JobNo" name="JobNo" placeholder="" class="col-xs-10 col-sm-5" data-val="true"  data-val-required="职位编号不允许为空" value="@Model.JobNo" />
                                                   
                                            <span class="field-validation-valid help-block" data-valmsg-for="JobNo" data-valmsg-replace="true"></span>

                                        </td>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">职位名称
                                        </td>
                                        <td colspan="3">
                                            <input  id="JobTitle" name="JobTitle" placeholder="" type="text" class="form-control" value="@Model.JobTitle" data-val="true" data-val-required="职位名称不允许为空" />
                                            <span class="field-validation-valid help-block" data-valmsg-for="JobTitle" data-valmsg-replace="true"></span>
                                        </td>
                                    </tr>
                                 
                                    <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">职位数量
                                        </td>
                                        <td>

                                            <input type="text" id="JobNum" name="JobNum" placeholder="" class="col-xs-10 col-sm-5" data-val="true"  data-val-number="职位数量为非法的数字格式" data-val-regex="职位数量为非法的数字格式"
                                                   data-val-regex-pattern="^(-?\d+)(\.\d+)?$" data-val-required="职位数量为非法的数字格式"  value="@Model.JobNum" />
                                                   
                                            <span class="field-validation-valid help-block" data-valmsg-for="JobNum" data-valmsg-replace="true"></span>

                                        </td>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">面试要求
                                        </td>
                                        <td colspan="3">
                                            <select class="form-control" id="JobInterview" name="JobInterview">
                                                @if (!string.IsNullOrEmpty(Model.JobInterview))
                                                {
                                                    <option value="@Model.JobInterview.Trim()">@Model.JobInterview.Trim()</option>
                                                }
                                                <option value="是">是</option>
                                                <option value="否">否</option>
                                              
                                            </select>
                                            
                                        </td>
                                    </tr>
                                       <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">工作日期
                                        </td>
                                        <td>

                                            <input type="text" id="WorkDate" name="WorkDate" placeholder="" class="form-control" data-val="true"  data-val-required="工作日期不允许为空" value="@Model.WorkDate" />
                                                   
                                            <span class="field-validation-valid help-block" data-valmsg-for="WorkDate" data-valmsg-replace="true"></span>

                                        </td>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">工作时间
                                        </td>
                                        <td colspan="3">
                                            <input  id="WorkTime" name="WorkTime" placeholder="" type="text" class="form-control" value="@Model.WorkTime" />
                                            
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">工作地点
                                        </td>
                                       <td colspan="3">
                                            <input  id="Workplace" name="Workplace" placeholder="" type="text" class="form-control" value="@Model.Workplace" data-val="true" data-val-required="工作地点不允许为空" />
                                            <span class="field-validation-valid help-block" data-valmsg-for="Workplace" data-valmsg-replace="true"></span>
                                        </td>
                                       
                                    </tr>
                                     <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">工资待遇
                                        </td>
                                        <td>
                                             <input  id="Salary" name="Salary" placeholder="" type="text" class="form-control" value="@Model.Salary" data-val="true" data-val-required="工资待遇不允许为空" />
                                            <span class="field-validation-valid help-block" data-valmsg-for="Salary" data-valmsg-replace="true"></span>
                                          
                                        </td>
                                         <td class="align-right" style="width: 15%; background: #f6f6f6">结算方式
                                        </td>
                                        <td>

                                            <select class="form-control" id="PayTypeId" name="PayTypeId">
                                              
                                                @foreach (var item in Model.BaseInfos.Where(x => x.FunctionName.Trim() == "工资结算方式"))
                                                {

                                                    strSelect = "";
                                                    if (Model.JobTypeId == item.Id)
                                                    {
                                                        strSelect = "selected";
                                                    }
                                                        <option value="@item.Id" @strSelect>@item.MasterType</option>
                                                }
                                                   
                                                }
                                            </select>

                                        </td>
                                       

                                    </tr>
                                    <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">性别限制
                                        </td>
                                        <td>
                                            <select class="form-control" id="GenderId" name="GenderId">
                                              
                                                @foreach (var item in Model.BaseInfos.Where(x => x.FunctionName.Trim() == "性别限制"))
                                                {

                                                    strSelect = "";
                                                    if (Model.JobTypeId == item.Id)
                                                    {
                                                        strSelect = "selected";
                                                    }
                                                    <option value="@item.Id" @strSelect>@item.MasterType</option>
                                                }
                                                   
                                                }
                                            </select>
                                          
                                        </td>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">身高要求
                                        </td>
                                        <td>

                                            <select class="form-control" id="BodyLengthId" name="BodyLengthId">
                                              
                                                @foreach (var item in Model.BaseInfos.Where(x => x.FunctionName.Trim() == "身高要求"))
                                                {

                                                    strSelect = "";
                                                    if (Model.JobTypeId == item.Id)
                                                    {
                                                        strSelect = "selected";
                                                    }
                                                    <option value="@item.Id" @strSelect>@item.MasterType</option>
                                                }
                                                   
                                                }
                                            </select>

                                        </td>
                                       

                                    </tr>
                                     <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">图片
                                        </td>
                                        <td>
                                            <img width="221" height="100" alt="221x100" id="img" src="@Model.JobPic" />


                                            <div class="btns" style="margin-top: 5px">
                                                <div id="picker">
                                                    点击选择图片(图片大小221x100)
                                                </div>

                                            </div>
                                            <input type="hidden" id="JobPic" name="JobPic" value="@Model.JobPic" />
                                        </td>
                                        <td class="align-right" style="width: 15%">职位属性
                                        </td>
                                        <td>
                                            <input type="checkbox" id="ReFlag" name="ReFlag"  value="1"  @strChk /> 悬赏
                                            <input type="checkbox" id="HotFlag" name="HotFlag"  value="1"  @strChk1/> 推荐
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">职位描述
                                        </td>
                                        <td colspan="3">
                                            <textarea id="JobDesc" name="JobDesc" class="form-control" style="height: 400px">@Model.JobDesc</textarea>

                                        </td>
                                    </tr>
                                   
                                    <tr>
                                            <td class="align-right" style="width: 15%; background: #f6f6f6">报名权限
                                        </td>
                                        <td>
                                               <select class="form-control" id="RegRank" name="RegRank">
                                                <option value="" >不限制</option>
                                                @foreach (var item in Model.BaseInfos.Where(x => x.FunctionName.Trim() == "会员类别"))
                                                {

                                                    strSelect = "";
                                                    if ( !string.IsNullOrEmpty(Model.RegRank))
                                                    {
                                                        if (Model.RegRank.Trim() == item.MasterType.Trim())
                                                        {
                                                            strSelect = "selected";
                                                        }
                                                        
                                                    }
                                                        <option value="@item.MasterType" @strSelect>@item.MasterType</option>
                                                }
                                                   
                                                }
                                            </select>
                                          
                                        </td>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">发布审核
                                        </td>
                                        <td >

                                            @*<input type="text" id="JobNum" name="JobNum" placeholder="" class="col-xs-10 col-sm-5" data-val="true"  data-val-number="职位数量为非法的数字格式" data-val-regex="职位数量为非法的数字格式"
                                                   data-val-regex-pattern="^(-?\d+)(\.\d+)?$" data-val-required="职位数量为非法的数字格式"  value="@Model.JobNum" />
                                                   
                                            <span class="field-validation-valid help-block" data-valmsg-for="JobNum" data-valmsg-replace="true"></span>*@
                                            <select class="form-control width-30" id="JobState" name="JobState">
                                                
                                                <option value="0" @s0>撤销</option>
                                                <option value="1" @s1>核准</option>
                                              
                                            </select>
                                        </td>
                                        
                                    </tr>

                                </tbody>
                            </table>
                        </div>


                        @if (ViewBag.scode == "1")
                        {
                            <div class="hr hr-2 dotted"></div>
                            <div class="alert alert-success">
                                <button type="button" class="close" data-dismiss="alert">
                                    <i class="icon-remove"></i>
                                </button>

                                <strong>
                                    <i class="icon-ok"></i>
                                    提示信息
                                </strong>

                                信息保存成功!
																
                            </div>
                        }
                        @if (ViewBag.scode == "0")
                        {
                            <div class="hr hr-2 dotted"></div>
                            <div class="alert alert-danger">
                                <button type="button" class="close" data-dismiss="alert">
                                    <i class="icon-remove"></i>
                                </button>

                                <strong>
                                    <i class="icon-remove"></i>
                                    错误提示
                                </strong>

                                @Html.ValidationSummary(true)

                            </div>

                        }
                        <div class="clearfix form-actions">
                            <div class="col-md-offset-3 col-md-9">
                                <button class="btn btn-info" type="submit">
                                    &nbsp;&nbsp;<i class="ace-icon fa fa-check bigger-110"></i>
                                    保存&nbsp;&nbsp;
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="button" onclick="funBack()">
                                    &nbsp;&nbsp;<i class="ace-icon fa fa-undo bigger-110"></i>
                                    返回&nbsp;&nbsp;
                                </button>
                            </div>
                        </div>




                    </div>



                </div>

            </div>
        }

    </div>


</div>
@section js{
    <script src="/assets/js/jquery.validate.min.js"></script>
    <script src="/assets/js/jquery.validate.unobtrusive.js"></script>
    <script src="/assets/js/jquery.validate.unobtrusive.bootstrap.js"></script>
    <script src="/assets/js/select2.js"></script>
    <script src="/assets/js/select2_locale_zh-CN.js"></script>
    <script charset="utf-8" src="/kindeditor/kindeditor-min.js" type="text/javascript"></script>
    <script charset="utf-8" src="/kindeditor/lang/zh_CN.js" type="text/javascript"></script>
    <script src="/Assets/webuploader/webuploader.js" type="text/javascript"></script>
     <script src="/assets/js/date-time/bootstrap-datepicker.min.js"></script>
    <script src="/assets/js/date-time/bootstrap-datepicker.zh-CN.js" ></script>
    <script type="text/javascript">
        KindEditor.ready(function (K) {
            var editor1 = K.create('#JobDesc', {
                cssPath: '/kindeditor/plugins/code/prettify.css',
                uploadJson: '/kindeditor/upload_json.ashx',
                fileManagerJson: '/kindeditor/file_manager_json.ashx'


            });
           

        });


        jQuery(function ($) {
            //$('#PubDate,#EndDate').datepicker({ autoclose: true, format: "yyyy-mm-dd", language: "zh-CN" });
            $('#PubDate,#EndDate').datepicker({
                autoclose: true,
                todayHighlight: true,
                language: "zh-CN"
            });
            @*$('#CustomerId').select2(
     {
         minimumInputLength: 0,
         ajax: {

             quietMillis: 150,

             url: '/GsnService/GetJobCustomer/@Model.ParentId',
                     dataType: 'json',
                     data: function (term) {
                         return {
                             term: term,

                         };
                     },
                     results: function (data, page) {

                         return { results: data.Results };
                     }
                 },


                 initSelection: function (element, callback) {

                     var q = '@Model.CustomerId';
                     if (q > 0) {
                         $.ajax("/GsnService/GetJobCustomer/@Model.ParentId", {
                             data: {
                                 initid: q
                             },
                             dataType: "json"

                         }).done(function (data) {
                             var r = { id: data.Results[0].id, text: data.Results[0].text };
                             callback(r);

                         });
                     }
                 },
             });*@
          
            var uploader = WebUploader.create({

                resize: true,

                // 自动上传。
                auto: true,

                // swf文件路径
                swf: '/Assets/webuploader/Uploader.swf',

                // 文件接收服务端。
                server: '/GsnService/UploadFileToQiniu/',

                // 选择文件的按钮。可选。
                // 内部根据当前运行是创建，可能是input元素，也可能是flash.
                pick: '#picker'
            });

            // 当有文件添加进来的时候
            //uploader.on('fileQueued', function (file) {
            //    $list.append('<div id="' + file.id + '" class="item">' +
            //    '<h4 class="info">' + file.name + '</h4>' +
            //    '<p class="state">等待上传...</p>' +
            //    '</div>');
            //});

            // 文件上传过程中创建进度条实时显示。
            uploader.on('uploadProgress', function (file, percentage) {
                var $li = $('#' + file.id),
            $percent = $li.find('.progress .progress-bar');
                // 避免重复创建
                if (!$percent.length) {
                    $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo($li).find('.progress-bar');
                }
                $li.find('p.state').text('上传中');

                $percent.css('width', percentage * 100 + '%');
            });
            uploader.on('uploadSuccess', function (file) {
                $('#' + file.id).find('p.state').text('已上传');
            });
            uploader.on('uploadError', function (file) {
                $('#' + file.id).find('p.state').text('上传出错');
            });
            // 完成上传完了，成功或者失败，先删除进度条。
            uploader.on('uploadComplete', function (file) {
                $('#' + file.id).find('.progress').fadeOut();
                //alert(file.name);
            });

            //获取返回值
            uploader.on('uploadAccept', function (file, response) {
                //response.FileName
                //  $('#fName').val(response.FileName);
                $('#JobPic').val(response.SavePath + response.SaveName);
                $('#img').attr("src", response.SavePath + response.SaveName);
            });

        });
        function funBack() {
            document.location = "/JobInfo/PubAudit/0?m=@ViewBag.m&f=@ViewBag.f&p=@ViewBag.p&fid=@ViewBag.fid&sdate=@ViewBag.sdate&edate=@ViewBag.edate&jname=@ViewBag.jname&pageIndex=@ViewBag.pageIndex";
        }
    </script>
}
